﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_Model
{
    public class VRBoardADModel
    {
        public int ad_id { get; set; }
        public int ad_order { get; set; }
        [Required(ErrorMessage = "产品类别不能为空")]
        public int pro_type { get; set; }
        [Required(ErrorMessage = "广告类别不能为空")]
        public string ad_type { get; set; }
        public string ad_url { get; set; }
        [Required(ErrorMessage = "标题不能为空")]
        public string ad_title { get; set; }
        [Required(ErrorMessage = "开始时间不能为空")]
        public string start_time { get; set; }
        [Required(ErrorMessage = "截止时间不能为空")]
        public string end_time { get; set; }
        public string ad_content { get; set; }
        public int create_id { get; set; }
        public string create_name { get; set; }
        public string create_time { get; set; }
        public int update_id { get; set; }
        public string update_name { get; set; }
        public string update_time { get; set; }
        public string ad_note { get; set; }
        public int ad_status { get; set; }
        /// <summary>
        ///  分组名
        /// </summary>
        public string group_name { get; set; }
        /// <summary>
        ///  视频地址
        /// </summary>
        public string video_url { get; set; }
        /// <summary>
        ///  店铺id
        /// </summary>
        public int store_id { get; set; }
        public int platType { get; set; } = 2;//默认web
        public T_VRBoardAD toEntry()
        {
            return new T_VRBoardAD
            {
                ad_id = ad_id,
                ad_order = ad_order,
                pro_type = pro_type,
                ad_type = ad_type,
                ad_url = ad_url,
                ad_title = ad_title,
                start_time = (!string.IsNullOrEmpty(start_time)) ? Convert.ToDateTime(start_time) : DateTime.Now,
                end_time = (!string.IsNullOrEmpty(end_time)) ? Convert.ToDateTime(end_time) : DateTime.Now,
                ad_content = ad_content,
                create_id = create_id,
                create_name = create_name,
                create_time = DateTime.Now,
                update_id = update_id,
                update_name = update_name,
                update_time = DateTime.Now,
                ad_note = ad_note,
                ad_status = ad_status,
                group_name = group_name,
                video_url = video_url,
                platType = platType,
                store_id = store_id
            };
        }
    }
    public partial class T_VRBoardAD
    {
        public VRBoardADModel toPOTO()
        {
            return new VRBoardADModel
            {
                ad_id = ad_id,
                ad_order = ad_order,
                pro_type = pro_type,
                ad_type = ad_type,
                ad_url = ad_url,
                ad_title = ad_title,
                start_time = start_time.ToString("yyyy-MM-dd HH:mm"),
                end_time = end_time.ToString("yyyy-MM-dd HH:mm"),
                ad_content = ad_content,
                create_id = create_id,
                create_name = create_name,
                create_time = create_time.ToString("yyyy-MM-dd HH:mm"),
                update_id = update_id,
                update_name = update_name,
                update_time = update_time.ToString("yyyy-MM-dd HH:mm"),
                ad_note = ad_note,
                ad_status = ad_status,
                group_name = group_name,
                video_url = video_url,
                platType = platType,
                store_id = store_id
            };
        }
    }
}